
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 10/30/2010 14:22:24
-- Generated from EDMX file: C:\Users\Ryan\Devel\arthea\ArtheaEngine\Model\ArtheaModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [Arthea];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_AreaRoom]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Rooms] DROP CONSTRAINT [FK_AreaRoom];
GO
IF OBJECT_ID(N'[dbo].[FK_RoomExit]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Exits] DROP CONSTRAINT [FK_RoomExit];
GO
IF OBJECT_ID(N'[dbo].[FK_ExitRoom]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Exits] DROP CONSTRAINT [FK_ExitRoom];
GO
IF OBJECT_ID(N'[dbo].[FK_ExitKeyObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_KeyObject] DROP CONSTRAINT [FK_ExitKeyObject];
GO
IF OBJECT_ID(N'[dbo].[FK_NoteReplyNote]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Notes_ReplyNote] DROP CONSTRAINT [FK_NoteReplyNote];
GO
IF OBJECT_ID(N'[dbo].[FK_BoardNote]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Notes] DROP CONSTRAINT [FK_BoardNote];
GO
IF OBJECT_ID(N'[dbo].[FK_AccountPlayer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Characters_Player] DROP CONSTRAINT [FK_AccountPlayer];
GO
IF OBJECT_ID(N'[dbo].[FK_BoardPlayerBoard]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PlayerBoards] DROP CONSTRAINT [FK_BoardPlayerBoard];
GO
IF OBJECT_ID(N'[dbo].[FK_PlayerPlayerBoard]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PlayerBoards] DROP CONSTRAINT [FK_PlayerPlayerBoard];
GO
IF OBJECT_ID(N'[dbo].[FK_AffectAbility]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Abilities] DROP CONSTRAINT [FK_AffectAbility];
GO
IF OBJECT_ID(N'[dbo].[FK_CharacterCharAffect]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Affects_CharAffect] DROP CONSTRAINT [FK_CharacterCharAffect];
GO
IF OBJECT_ID(N'[dbo].[FK_ObjectObjectAffect]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Affects_ObjectAffect] DROP CONSTRAINT [FK_ObjectObjectAffect];
GO
IF OBJECT_ID(N'[dbo].[FK_ObjectCharObj]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CharObjs] DROP CONSTRAINT [FK_ObjectCharObj];
GO
IF OBJECT_ID(N'[dbo].[FK_CharacterCharObj]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CharObjs] DROP CONSTRAINT [FK_CharacterCharObj];
GO
IF OBJECT_ID(N'[dbo].[FK_CharResetNonPlayer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_CharReset] DROP CONSTRAINT [FK_CharResetNonPlayer];
GO
IF OBJECT_ID(N'[dbo].[FK_ContainerObjectKeyObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_KeyObject] DROP CONSTRAINT [FK_ContainerObjectKeyObject];
GO
IF OBJECT_ID(N'[dbo].[FK_EquipResetObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_EquipReset] DROP CONSTRAINT [FK_EquipResetObject];
GO
IF OBJECT_ID(N'[dbo].[FK_GiveResetNonPlayer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_GiveReset] DROP CONSTRAINT [FK_GiveResetNonPlayer];
GO
IF OBJECT_ID(N'[dbo].[FK_GiveResetObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_GiveReset] DROP CONSTRAINT [FK_GiveResetObject];
GO
IF OBJECT_ID(N'[dbo].[FK_HelpHelp]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Helps] DROP CONSTRAINT [FK_HelpHelp];
GO
IF OBJECT_ID(N'[dbo].[FK_HelpHelpTag]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[HelpTags] DROP CONSTRAINT [FK_HelpHelpTag];
GO
IF OBJECT_ID(N'[dbo].[FK_NonPlayerArea]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Characters_NonPlayer] DROP CONSTRAINT [FK_NonPlayerArea];
GO
IF OBJECT_ID(N'[dbo].[FK_ObjectRoom]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects] DROP CONSTRAINT [FK_ObjectRoom];
GO
IF OBJECT_ID(N'[dbo].[FK_WorldArea1]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Areas] DROP CONSTRAINT [FK_WorldArea1];
GO
IF OBJECT_ID(N'[dbo].[FK_AreaObject1]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects] DROP CONSTRAINT [FK_AreaObject1];
GO
IF OBJECT_ID(N'[dbo].[FK_CharacterObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects] DROP CONSTRAINT [FK_CharacterObject];
GO
IF OBJECT_ID(N'[dbo].[FK_ObjResetObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_ObjReset] DROP CONSTRAINT [FK_ObjResetObject];
GO
IF OBJECT_ID(N'[dbo].[FK_PotionScrollPillObjectSpell]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Abilities_Spell] DROP CONSTRAINT [FK_PotionScrollPillObjectSpell];
GO
IF OBJECT_ID(N'[dbo].[FK_PutResetObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_PutReset] DROP CONSTRAINT [FK_PutResetObject];
GO
IF OBJECT_ID(N'[dbo].[FK_WandStaffObjectSpell]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_WandStaffObject] DROP CONSTRAINT [FK_WandStaffObjectSpell];
GO
IF OBJECT_ID(N'[dbo].[FK_RoomCharacter]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Characters] DROP CONSTRAINT [FK_RoomCharacter];
GO
IF OBJECT_ID(N'[dbo].[FK_RaceCharacter]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Characters] DROP CONSTRAINT [FK_RaceCharacter];
GO
IF OBJECT_ID(N'[dbo].[FK_ClassPlayer]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Characters_Player] DROP CONSTRAINT [FK_ClassPlayer];
GO
IF OBJECT_ID(N'[dbo].[FK_SuperResetSubReset]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_SubReset] DROP CONSTRAINT [FK_SuperResetSubReset];
GO
IF OBJECT_ID(N'[dbo].[FK_ContainerObjectObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects] DROP CONSTRAINT [FK_ContainerObjectObject];
GO
IF OBJECT_ID(N'[dbo].[FK_RoomSuperReset]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_SuperReset] DROP CONSTRAINT [FK_RoomSuperReset];
GO
IF OBJECT_ID(N'[dbo].[FK_KeyObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_KeyObject] DROP CONSTRAINT [FK_KeyObject_inherits_Object];
GO
IF OBJECT_ID(N'[dbo].[FK_ReplyNote_inherits_Note]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Notes_ReplyNote] DROP CONSTRAINT [FK_ReplyNote_inherits_Note];
GO
IF OBJECT_ID(N'[dbo].[FK_Player_inherits_Character]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Characters_Player] DROP CONSTRAINT [FK_Player_inherits_Character];
GO
IF OBJECT_ID(N'[dbo].[FK_CharAffect_inherits_Affect]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Affects_CharAffect] DROP CONSTRAINT [FK_CharAffect_inherits_Affect];
GO
IF OBJECT_ID(N'[dbo].[FK_ObjectAffect_inherits_Affect]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Affects_ObjectAffect] DROP CONSTRAINT [FK_ObjectAffect_inherits_Affect];
GO
IF OBJECT_ID(N'[dbo].[FK_SuperReset_inherits_Reset]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_SuperReset] DROP CONSTRAINT [FK_SuperReset_inherits_Reset];
GO
IF OBJECT_ID(N'[dbo].[FK_CharReset_inherits_SuperReset]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_CharReset] DROP CONSTRAINT [FK_CharReset_inherits_SuperReset];
GO
IF OBJECT_ID(N'[dbo].[FK_NonPlayer_inherits_Character]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Characters_NonPlayer] DROP CONSTRAINT [FK_NonPlayer_inherits_Character];
GO
IF OBJECT_ID(N'[dbo].[FK_ContainerObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_ContainerObject] DROP CONSTRAINT [FK_ContainerObject_inherits_Object];
GO
IF OBJECT_ID(N'[dbo].[FK_SubReset_inherits_Reset]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_SubReset] DROP CONSTRAINT [FK_SubReset_inherits_Reset];
GO
IF OBJECT_ID(N'[dbo].[FK_EquipReset_inherits_SubReset]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_EquipReset] DROP CONSTRAINT [FK_EquipReset_inherits_SubReset];
GO
IF OBJECT_ID(N'[dbo].[FK_GiveReset_inherits_SubReset]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_GiveReset] DROP CONSTRAINT [FK_GiveReset_inherits_SubReset];
GO
IF OBJECT_ID(N'[dbo].[FK_ObjReset_inherits_SuperReset]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_ObjReset] DROP CONSTRAINT [FK_ObjReset_inherits_SuperReset];
GO
IF OBJECT_ID(N'[dbo].[FK_PotionScrollPillObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_PotionScrollPillObject] DROP CONSTRAINT [FK_PotionScrollPillObject_inherits_Object];
GO
IF OBJECT_ID(N'[dbo].[FK_Spell_inherits_Ability]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Abilities_Spell] DROP CONSTRAINT [FK_Spell_inherits_Ability];
GO
IF OBJECT_ID(N'[dbo].[FK_PutReset_inherits_SubReset]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Resets_PutReset] DROP CONSTRAINT [FK_PutReset_inherits_SubReset];
GO
IF OBJECT_ID(N'[dbo].[FK_WandStaffObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_WandStaffObject] DROP CONSTRAINT [FK_WandStaffObject_inherits_Object];
GO
IF OBJECT_ID(N'[dbo].[FK_MageClass_inherits_Class]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Classes_MageClass] DROP CONSTRAINT [FK_MageClass_inherits_Class];
GO
IF OBJECT_ID(N'[dbo].[FK_WarriorClass_inherits_Class]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Classes_WarriorClass] DROP CONSTRAINT [FK_WarriorClass_inherits_Class];
GO
IF OBJECT_ID(N'[dbo].[FK_PcRace_inherits_Race]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Races_PcRace] DROP CONSTRAINT [FK_PcRace_inherits_Race];
GO
IF OBJECT_ID(N'[dbo].[FK_HumanRace_inherits_PcRace]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Races_HumanRace] DROP CONSTRAINT [FK_HumanRace_inherits_PcRace];
GO
IF OBJECT_ID(N'[dbo].[FK_DwarfRace_inherits_PcRace]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Races_DwarfRace] DROP CONSTRAINT [FK_DwarfRace_inherits_PcRace];
GO
IF OBJECT_ID(N'[dbo].[FK_ArmorObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_ArmorObject] DROP CONSTRAINT [FK_ArmorObject_inherits_Object];
GO
IF OBJECT_ID(N'[dbo].[FK_WeaponObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_WeaponObject] DROP CONSTRAINT [FK_WeaponObject_inherits_Object];
GO
IF OBJECT_ID(N'[dbo].[FK_Skill_inherits_Ability]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Abilities_Skill] DROP CONSTRAINT [FK_Skill_inherits_Ability];
GO
IF OBJECT_ID(N'[dbo].[FK_KickSkill_inherits_Skill]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Abilities_KickSkill] DROP CONSTRAINT [FK_KickSkill_inherits_Skill];
GO
IF OBJECT_ID(N'[dbo].[FK_HealSpell_inherits_Spell]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Abilities_HealSpell] DROP CONSTRAINT [FK_HealSpell_inherits_Spell];
GO
IF OBJECT_ID(N'[dbo].[FK_AnnounceBoard_inherits_Board]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Boards_AnnounceBoard] DROP CONSTRAINT [FK_AnnounceBoard_inherits_Board];
GO
IF OBJECT_ID(N'[dbo].[FK_DrinkContainerObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_DrinkContainerObject] DROP CONSTRAINT [FK_DrinkContainerObject_inherits_Object];
GO
IF OBJECT_ID(N'[dbo].[FK_FoodObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_FoodObject] DROP CONSTRAINT [FK_FoodObject_inherits_Object];
GO
IF OBJECT_ID(N'[dbo].[FK_FurnitureObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_FurnitureObject] DROP CONSTRAINT [FK_FurnitureObject_inherits_Object];
GO
IF OBJECT_ID(N'[dbo].[FK_MoneyObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_MoneyObject] DROP CONSTRAINT [FK_MoneyObject_inherits_Object];
GO
IF OBJECT_ID(N'[dbo].[FK_PotionObject_inherits_PotionScrollPillObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_PotionObject] DROP CONSTRAINT [FK_PotionObject_inherits_PotionScrollPillObject];
GO
IF OBJECT_ID(N'[dbo].[FK_ScrollObject_inherits_PotionScrollPillObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_ScrollObject] DROP CONSTRAINT [FK_ScrollObject_inherits_PotionScrollPillObject];
GO
IF OBJECT_ID(N'[dbo].[FK_PillObject_inherits_PotionScrollPillObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_PillObject] DROP CONSTRAINT [FK_PillObject_inherits_PotionScrollPillObject];
GO
IF OBJECT_ID(N'[dbo].[FK_PortalObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_PortalObject] DROP CONSTRAINT [FK_PortalObject_inherits_Object];
GO
IF OBJECT_ID(N'[dbo].[FK_StaffObject_inherits_WandStaffObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_StaffObject] DROP CONSTRAINT [FK_StaffObject_inherits_WandStaffObject];
GO
IF OBJECT_ID(N'[dbo].[FK_WandObject_inherits_WandStaffObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_WandObject] DROP CONSTRAINT [FK_WandObject_inherits_WandStaffObject];
GO
IF OBJECT_ID(N'[dbo].[FK_TrashObject_inherits_Object]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Objects_TrashObject] DROP CONSTRAINT [FK_TrashObject_inherits_Object];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Worlds]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Worlds];
GO
IF OBJECT_ID(N'[dbo].[Characters]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Characters];
GO
IF OBJECT_ID(N'[dbo].[Rooms]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Rooms];
GO
IF OBJECT_ID(N'[dbo].[Areas]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Areas];
GO
IF OBJECT_ID(N'[dbo].[Socials]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Socials];
GO
IF OBJECT_ID(N'[dbo].[Classes]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Classes];
GO
IF OBJECT_ID(N'[dbo].[Races]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Races];
GO
IF OBJECT_ID(N'[dbo].[Accounts]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Accounts];
GO
IF OBJECT_ID(N'[dbo].[Resets]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Resets];
GO
IF OBJECT_ID(N'[dbo].[Objects]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects];
GO
IF OBJECT_ID(N'[dbo].[Abilities]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Abilities];
GO
IF OBJECT_ID(N'[dbo].[Exits]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Exits];
GO
IF OBJECT_ID(N'[dbo].[Notes]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Notes];
GO
IF OBJECT_ID(N'[dbo].[Boards]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Boards];
GO
IF OBJECT_ID(N'[dbo].[PlayerBoards]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PlayerBoards];
GO
IF OBJECT_ID(N'[dbo].[Affects]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Affects];
GO
IF OBJECT_ID(N'[dbo].[CharObjs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CharObjs];
GO
IF OBJECT_ID(N'[dbo].[Helps]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Helps];
GO
IF OBJECT_ID(N'[dbo].[HelpTags]', 'U') IS NOT NULL
    DROP TABLE [dbo].[HelpTags];
GO
IF OBJECT_ID(N'[dbo].[Objects_KeyObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_KeyObject];
GO
IF OBJECT_ID(N'[dbo].[Notes_ReplyNote]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Notes_ReplyNote];
GO
IF OBJECT_ID(N'[dbo].[Characters_Player]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Characters_Player];
GO
IF OBJECT_ID(N'[dbo].[Affects_CharAffect]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Affects_CharAffect];
GO
IF OBJECT_ID(N'[dbo].[Affects_ObjectAffect]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Affects_ObjectAffect];
GO
IF OBJECT_ID(N'[dbo].[Resets_SuperReset]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Resets_SuperReset];
GO
IF OBJECT_ID(N'[dbo].[Resets_CharReset]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Resets_CharReset];
GO
IF OBJECT_ID(N'[dbo].[Characters_NonPlayer]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Characters_NonPlayer];
GO
IF OBJECT_ID(N'[dbo].[Objects_ContainerObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_ContainerObject];
GO
IF OBJECT_ID(N'[dbo].[Resets_SubReset]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Resets_SubReset];
GO
IF OBJECT_ID(N'[dbo].[Resets_EquipReset]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Resets_EquipReset];
GO
IF OBJECT_ID(N'[dbo].[Resets_GiveReset]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Resets_GiveReset];
GO
IF OBJECT_ID(N'[dbo].[Resets_ObjReset]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Resets_ObjReset];
GO
IF OBJECT_ID(N'[dbo].[Objects_PotionScrollPillObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_PotionScrollPillObject];
GO
IF OBJECT_ID(N'[dbo].[Abilities_Spell]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Abilities_Spell];
GO
IF OBJECT_ID(N'[dbo].[Resets_PutReset]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Resets_PutReset];
GO
IF OBJECT_ID(N'[dbo].[Objects_WandStaffObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_WandStaffObject];
GO
IF OBJECT_ID(N'[dbo].[Classes_MageClass]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Classes_MageClass];
GO
IF OBJECT_ID(N'[dbo].[Classes_WarriorClass]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Classes_WarriorClass];
GO
IF OBJECT_ID(N'[dbo].[Races_PcRace]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Races_PcRace];
GO
IF OBJECT_ID(N'[dbo].[Races_HumanRace]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Races_HumanRace];
GO
IF OBJECT_ID(N'[dbo].[Races_DwarfRace]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Races_DwarfRace];
GO
IF OBJECT_ID(N'[dbo].[Objects_ArmorObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_ArmorObject];
GO
IF OBJECT_ID(N'[dbo].[Objects_WeaponObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_WeaponObject];
GO
IF OBJECT_ID(N'[dbo].[Abilities_Skill]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Abilities_Skill];
GO
IF OBJECT_ID(N'[dbo].[Abilities_KickSkill]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Abilities_KickSkill];
GO
IF OBJECT_ID(N'[dbo].[Abilities_HealSpell]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Abilities_HealSpell];
GO
IF OBJECT_ID(N'[dbo].[Boards_AnnounceBoard]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Boards_AnnounceBoard];
GO
IF OBJECT_ID(N'[dbo].[Objects_DrinkContainerObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_DrinkContainerObject];
GO
IF OBJECT_ID(N'[dbo].[Objects_FoodObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_FoodObject];
GO
IF OBJECT_ID(N'[dbo].[Objects_FurnitureObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_FurnitureObject];
GO
IF OBJECT_ID(N'[dbo].[Objects_MoneyObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_MoneyObject];
GO
IF OBJECT_ID(N'[dbo].[Objects_PotionObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_PotionObject];
GO
IF OBJECT_ID(N'[dbo].[Objects_ScrollObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_ScrollObject];
GO
IF OBJECT_ID(N'[dbo].[Objects_PillObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_PillObject];
GO
IF OBJECT_ID(N'[dbo].[Objects_PortalObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_PortalObject];
GO
IF OBJECT_ID(N'[dbo].[Objects_StaffObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_StaffObject];
GO
IF OBJECT_ID(N'[dbo].[Objects_WandObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_WandObject];
GO
IF OBJECT_ID(N'[dbo].[Objects_TrashObject]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Objects_TrashObject];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Worlds'
CREATE TABLE [dbo].[Worlds] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Port] smallint  NOT NULL
);
GO

-- Creating table 'Characters'
CREATE TABLE [dbo].[Characters] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Description] nvarchar(max)  NULL,
    [Flags_Value] bigint  NOT NULL,
    [Level] smallint  NOT NULL,
    [Position_Value] int  NOT NULL,
    [Size] real  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Sex_Value] int  NOT NULL,
    [Room_Id] bigint  NOT NULL,
    [Race_Id] bigint  NULL
);
GO

-- Creating table 'Rooms'
CREATE TABLE [dbo].[Rooms] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [AreaId] bigint  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [Terrain_Value] int  NOT NULL,
    [Flags_Value] bigint  NOT NULL
);
GO

-- Creating table 'Areas'
CREATE TABLE [dbo].[Areas] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Credits] nvarchar(max)  NOT NULL,
    [Description] nvarchar(max)  NULL,
    [World_Id] bigint  NOT NULL
);
GO

-- Creating table 'Socials'
CREATE TABLE [dbo].[Socials] (
    [Id] bigint IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'Classes'
CREATE TABLE [dbo].[Classes] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Description] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Races'
CREATE TABLE [dbo].[Races] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Description] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Accounts'
CREATE TABLE [dbo].[Accounts] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Login] nvarchar(max)  NOT NULL,
    [Password] varbinary(max)  NOT NULL,
    [Email] nvarchar(max)  NOT NULL,
    [Flags_Value] bigint  NOT NULL
);
GO

-- Creating table 'Resets'
CREATE TABLE [dbo].[Resets] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Objects'
CREATE TABLE [dbo].[Objects] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Condition] real  NOT NULL,
    [Cost_Value] decimal(18,0)  NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [Flags_Value] bigint  NOT NULL,
    [Level] smallint  NOT NULL,
    [LongDescr] nvarchar(max)  NOT NULL,
    [ShortDescr] nvarchar(max)  NOT NULL,
    [WearFlags_Value] bigint  NOT NULL,
    [Weight] real  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Room_Id] bigint  NULL,
    [Area_Id] bigint  NOT NULL,
    [CarriedBy_Id] bigint  NOT NULL,
    [Inside_Id] bigint  NULL
);
GO

-- Creating table 'Abilities'
CREATE TABLE [dbo].[Abilities] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Cost_Value] decimal(18,0)  NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [Level] smallint  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [AffectAbility_Ability_Id] bigint  NOT NULL
);
GO

-- Creating table 'Exits'
CREATE TABLE [dbo].[Exits] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [RoomId] bigint  NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [Flags] bigint  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [ToRoom_Id] bigint  NOT NULL
);
GO

-- Creating table 'Notes'
CREATE TABLE [dbo].[Notes] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [From] nvarchar(max)  NOT NULL,
    [Subject] nvarchar(max)  NOT NULL,
    [Text] nvarchar(max)  NOT NULL,
    [To] nvarchar(max)  NOT NULL,
    [When] datetime  NOT NULL,
    [BoardId] bigint  NOT NULL
);
GO

-- Creating table 'Boards'
CREATE TABLE [dbo].[Boards] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [ReadPermission_Value] int  NOT NULL,
    [WritePermission_Value] int  NOT NULL
);
GO

-- Creating table 'PlayerBoards'
CREATE TABLE [dbo].[PlayerBoards] (
    [Id] bigint  NOT NULL,
    [LastNote] datetime  NOT NULL,
    [Board_Id] bigint  NOT NULL,
    [Player_Id] bigint  NOT NULL
);
GO

-- Creating table 'Affects'
CREATE TABLE [dbo].[Affects] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Duration] int  NOT NULL,
    [Flag_Value] bigint  NOT NULL,
    [Modifier] int  NOT NULL,
    [Where_Value] int  NOT NULL
);
GO

-- Creating table 'CharObjs'
CREATE TABLE [dbo].[CharObjs] (
    [WearLocation_Value] int  NOT NULL,
    [Id] bigint  NOT NULL,
    [Object_Id] bigint  NOT NULL,
    [Character_Id] bigint  NOT NULL
);
GO

-- Creating table 'Helps'
CREATE TABLE [dbo].[Helps] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Category_Value] bigint  NOT NULL,
    [Text] nvarchar(max)  NOT NULL,
    [HelpHelp_Help1_Id] bigint  NOT NULL
);
GO

-- Creating table 'HelpTags'
CREATE TABLE [dbo].[HelpTags] (
    [Id] bigint IDENTITY(1,1) NOT NULL,
    [Tag] nvarchar(max)  NOT NULL,
    [Help_Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_KeyObject'
CREATE TABLE [dbo].[Objects_KeyObject] (
    [Id] bigint  NOT NULL,
    [ExitKeyObject_KeyObject_Id] bigint  NULL,
    [ContainerObjectKeyObject_KeyObject_Id] bigint  NOT NULL
);
GO

-- Creating table 'Notes_ReplyNote'
CREATE TABLE [dbo].[Notes_ReplyNote] (
    [Id] bigint  NOT NULL,
    [Original_Id] bigint  NOT NULL
);
GO

-- Creating table 'Characters_Player'
CREATE TABLE [dbo].[Characters_Player] (
    [Title] nvarchar(max)  NULL,
    [ChannelFlags_Value] bigint  NOT NULL,
    [Id] bigint  NOT NULL,
    [Account_Id] bigint  NOT NULL,
    [Class_Id] bigint  NULL
);
GO

-- Creating table 'Affects_CharAffect'
CREATE TABLE [dbo].[Affects_CharAffect] (
    [Id] bigint  NOT NULL,
    [Character_Id] bigint  NOT NULL
);
GO

-- Creating table 'Affects_ObjectAffect'
CREATE TABLE [dbo].[Affects_ObjectAffect] (
    [Id] bigint  NOT NULL,
    [Object_Id] bigint  NOT NULL
);
GO

-- Creating table 'Resets_SuperReset'
CREATE TABLE [dbo].[Resets_SuperReset] (
    [Id] bigint  NOT NULL,
    [Room_Id] bigint  NULL
);
GO

-- Creating table 'Resets_CharReset'
CREATE TABLE [dbo].[Resets_CharReset] (
    [Count] smallint  NOT NULL,
    [Id] bigint  NOT NULL,
    [Character_Id] bigint  NOT NULL
);
GO

-- Creating table 'Characters_NonPlayer'
CREATE TABLE [dbo].[Characters_NonPlayer] (
    [LongDescr] nvarchar(max)  NOT NULL,
    [ShortDescr] nvarchar(max)  NOT NULL,
    [Id] bigint  NOT NULL,
    [Area_Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_ContainerObject'
CREATE TABLE [dbo].[Objects_ContainerObject] (
    [Max] int  NOT NULL,
    [ContainerFlags_Value] bigint  NOT NULL,
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Resets_SubReset'
CREATE TABLE [dbo].[Resets_SubReset] (
    [Id] bigint  NOT NULL,
    [SuperReset_Id] bigint  NULL
);
GO

-- Creating table 'Resets_EquipReset'
CREATE TABLE [dbo].[Resets_EquipReset] (
    [WearLocation_Value] int  NOT NULL,
    [Id] bigint  NOT NULL,
    [Object_Id] bigint  NOT NULL
);
GO

-- Creating table 'Resets_GiveReset'
CREATE TABLE [dbo].[Resets_GiveReset] (
    [Id] bigint  NOT NULL,
    [NonPlayer_Id] bigint  NOT NULL,
    [Object_Id] bigint  NOT NULL
);
GO

-- Creating table 'Resets_ObjReset'
CREATE TABLE [dbo].[Resets_ObjReset] (
    [Count] smallint  NOT NULL,
    [Id] bigint  NOT NULL,
    [Object_Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_PotionScrollPillObject'
CREATE TABLE [dbo].[Objects_PotionScrollPillObject] (
    [V1_Value] bigint  NOT NULL,
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Abilities_Spell'
CREATE TABLE [dbo].[Abilities_Spell] (
    [Id] bigint  NOT NULL,
    [PotionScrollPillObjectSpell_Spell_Id] bigint  NOT NULL
);
GO

-- Creating table 'Resets_PutReset'
CREATE TABLE [dbo].[Resets_PutReset] (
    [Count] smallint  NOT NULL,
    [Id] bigint  NOT NULL,
    [Object_Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_WandStaffObject'
CREATE TABLE [dbo].[Objects_WandStaffObject] (
    [V1] int  NOT NULL,
    [V2] int  NOT NULL,
    [V3] int  NOT NULL,
    [Id] bigint  NOT NULL,
    [Spell_Id] bigint  NOT NULL
);
GO

-- Creating table 'Classes_MageClass'
CREATE TABLE [dbo].[Classes_MageClass] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Classes_WarriorClass'
CREATE TABLE [dbo].[Classes_WarriorClass] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Races_PcRace'
CREATE TABLE [dbo].[Races_PcRace] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Races_HumanRace'
CREATE TABLE [dbo].[Races_HumanRace] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Races_DwarfRace'
CREATE TABLE [dbo].[Races_DwarfRace] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_ArmorObject'
CREATE TABLE [dbo].[Objects_ArmorObject] (
    [Armor] int  NOT NULL,
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_WeaponObject'
CREATE TABLE [dbo].[Objects_WeaponObject] (
    [WeaponClass_Value] int  NOT NULL,
    [V1] int  NOT NULL,
    [V2] int  NOT NULL,
    [V3] nvarchar(max)  NOT NULL,
    [V4_Value] bigint  NOT NULL,
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Abilities_Skill'
CREATE TABLE [dbo].[Abilities_Skill] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Abilities_KickSkill'
CREATE TABLE [dbo].[Abilities_KickSkill] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Abilities_HealSpell'
CREATE TABLE [dbo].[Abilities_HealSpell] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Boards_AnnounceBoard'
CREATE TABLE [dbo].[Boards_AnnounceBoard] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_DrinkContainerObject'
CREATE TABLE [dbo].[Objects_DrinkContainerObject] (
    [V1] int  NOT NULL,
    [V2] int  NOT NULL,
    [Liquid] nvarchar(max)  NOT NULL,
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_FoodObject'
CREATE TABLE [dbo].[Objects_FoodObject] (
    [V1] int  NOT NULL,
    [FoodFlags_Value] bigint  NOT NULL,
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_FurnitureObject'
CREATE TABLE [dbo].[Objects_FurnitureObject] (
    [V1] int  NOT NULL,
    [FurnitureFlags_Value] bigint  NOT NULL,
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_MoneyObject'
CREATE TABLE [dbo].[Objects_MoneyObject] (
    [Value_Value] decimal(18,0)  NOT NULL,
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_PotionObject'
CREATE TABLE [dbo].[Objects_PotionObject] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_ScrollObject'
CREATE TABLE [dbo].[Objects_ScrollObject] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_PillObject'
CREATE TABLE [dbo].[Objects_PillObject] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_PortalObject'
CREATE TABLE [dbo].[Objects_PortalObject] (
    [V1] smallint  NOT NULL,
    [V2_Value] bigint  NOT NULL,
    [V3_Value] bigint  NOT NULL,
    [V4] int  NOT NULL,
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_StaffObject'
CREATE TABLE [dbo].[Objects_StaffObject] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_WandObject'
CREATE TABLE [dbo].[Objects_WandObject] (
    [Id] bigint  NOT NULL
);
GO

-- Creating table 'Objects_TrashObject'
CREATE TABLE [dbo].[Objects_TrashObject] (
    [Id] bigint  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'Worlds'
ALTER TABLE [dbo].[Worlds]
ADD CONSTRAINT [PK_Worlds]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Characters'
ALTER TABLE [dbo].[Characters]
ADD CONSTRAINT [PK_Characters]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Rooms'
ALTER TABLE [dbo].[Rooms]
ADD CONSTRAINT [PK_Rooms]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Areas'
ALTER TABLE [dbo].[Areas]
ADD CONSTRAINT [PK_Areas]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Socials'
ALTER TABLE [dbo].[Socials]
ADD CONSTRAINT [PK_Socials]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Classes'
ALTER TABLE [dbo].[Classes]
ADD CONSTRAINT [PK_Classes]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Races'
ALTER TABLE [dbo].[Races]
ADD CONSTRAINT [PK_Races]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Accounts'
ALTER TABLE [dbo].[Accounts]
ADD CONSTRAINT [PK_Accounts]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Resets'
ALTER TABLE [dbo].[Resets]
ADD CONSTRAINT [PK_Resets]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects'
ALTER TABLE [dbo].[Objects]
ADD CONSTRAINT [PK_Objects]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Abilities'
ALTER TABLE [dbo].[Abilities]
ADD CONSTRAINT [PK_Abilities]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Exits'
ALTER TABLE [dbo].[Exits]
ADD CONSTRAINT [PK_Exits]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Notes'
ALTER TABLE [dbo].[Notes]
ADD CONSTRAINT [PK_Notes]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Boards'
ALTER TABLE [dbo].[Boards]
ADD CONSTRAINT [PK_Boards]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PlayerBoards'
ALTER TABLE [dbo].[PlayerBoards]
ADD CONSTRAINT [PK_PlayerBoards]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Affects'
ALTER TABLE [dbo].[Affects]
ADD CONSTRAINT [PK_Affects]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'CharObjs'
ALTER TABLE [dbo].[CharObjs]
ADD CONSTRAINT [PK_CharObjs]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Helps'
ALTER TABLE [dbo].[Helps]
ADD CONSTRAINT [PK_Helps]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'HelpTags'
ALTER TABLE [dbo].[HelpTags]
ADD CONSTRAINT [PK_HelpTags]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_KeyObject'
ALTER TABLE [dbo].[Objects_KeyObject]
ADD CONSTRAINT [PK_Objects_KeyObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Notes_ReplyNote'
ALTER TABLE [dbo].[Notes_ReplyNote]
ADD CONSTRAINT [PK_Notes_ReplyNote]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Characters_Player'
ALTER TABLE [dbo].[Characters_Player]
ADD CONSTRAINT [PK_Characters_Player]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Affects_CharAffect'
ALTER TABLE [dbo].[Affects_CharAffect]
ADD CONSTRAINT [PK_Affects_CharAffect]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Affects_ObjectAffect'
ALTER TABLE [dbo].[Affects_ObjectAffect]
ADD CONSTRAINT [PK_Affects_ObjectAffect]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Resets_SuperReset'
ALTER TABLE [dbo].[Resets_SuperReset]
ADD CONSTRAINT [PK_Resets_SuperReset]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Resets_CharReset'
ALTER TABLE [dbo].[Resets_CharReset]
ADD CONSTRAINT [PK_Resets_CharReset]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Characters_NonPlayer'
ALTER TABLE [dbo].[Characters_NonPlayer]
ADD CONSTRAINT [PK_Characters_NonPlayer]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_ContainerObject'
ALTER TABLE [dbo].[Objects_ContainerObject]
ADD CONSTRAINT [PK_Objects_ContainerObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Resets_SubReset'
ALTER TABLE [dbo].[Resets_SubReset]
ADD CONSTRAINT [PK_Resets_SubReset]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Resets_EquipReset'
ALTER TABLE [dbo].[Resets_EquipReset]
ADD CONSTRAINT [PK_Resets_EquipReset]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Resets_GiveReset'
ALTER TABLE [dbo].[Resets_GiveReset]
ADD CONSTRAINT [PK_Resets_GiveReset]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Resets_ObjReset'
ALTER TABLE [dbo].[Resets_ObjReset]
ADD CONSTRAINT [PK_Resets_ObjReset]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_PotionScrollPillObject'
ALTER TABLE [dbo].[Objects_PotionScrollPillObject]
ADD CONSTRAINT [PK_Objects_PotionScrollPillObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Abilities_Spell'
ALTER TABLE [dbo].[Abilities_Spell]
ADD CONSTRAINT [PK_Abilities_Spell]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Resets_PutReset'
ALTER TABLE [dbo].[Resets_PutReset]
ADD CONSTRAINT [PK_Resets_PutReset]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_WandStaffObject'
ALTER TABLE [dbo].[Objects_WandStaffObject]
ADD CONSTRAINT [PK_Objects_WandStaffObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Classes_MageClass'
ALTER TABLE [dbo].[Classes_MageClass]
ADD CONSTRAINT [PK_Classes_MageClass]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Classes_WarriorClass'
ALTER TABLE [dbo].[Classes_WarriorClass]
ADD CONSTRAINT [PK_Classes_WarriorClass]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Races_PcRace'
ALTER TABLE [dbo].[Races_PcRace]
ADD CONSTRAINT [PK_Races_PcRace]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Races_HumanRace'
ALTER TABLE [dbo].[Races_HumanRace]
ADD CONSTRAINT [PK_Races_HumanRace]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Races_DwarfRace'
ALTER TABLE [dbo].[Races_DwarfRace]
ADD CONSTRAINT [PK_Races_DwarfRace]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_ArmorObject'
ALTER TABLE [dbo].[Objects_ArmorObject]
ADD CONSTRAINT [PK_Objects_ArmorObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_WeaponObject'
ALTER TABLE [dbo].[Objects_WeaponObject]
ADD CONSTRAINT [PK_Objects_WeaponObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Abilities_Skill'
ALTER TABLE [dbo].[Abilities_Skill]
ADD CONSTRAINT [PK_Abilities_Skill]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Abilities_KickSkill'
ALTER TABLE [dbo].[Abilities_KickSkill]
ADD CONSTRAINT [PK_Abilities_KickSkill]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Abilities_HealSpell'
ALTER TABLE [dbo].[Abilities_HealSpell]
ADD CONSTRAINT [PK_Abilities_HealSpell]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Boards_AnnounceBoard'
ALTER TABLE [dbo].[Boards_AnnounceBoard]
ADD CONSTRAINT [PK_Boards_AnnounceBoard]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_DrinkContainerObject'
ALTER TABLE [dbo].[Objects_DrinkContainerObject]
ADD CONSTRAINT [PK_Objects_DrinkContainerObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_FoodObject'
ALTER TABLE [dbo].[Objects_FoodObject]
ADD CONSTRAINT [PK_Objects_FoodObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_FurnitureObject'
ALTER TABLE [dbo].[Objects_FurnitureObject]
ADD CONSTRAINT [PK_Objects_FurnitureObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_MoneyObject'
ALTER TABLE [dbo].[Objects_MoneyObject]
ADD CONSTRAINT [PK_Objects_MoneyObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_PotionObject'
ALTER TABLE [dbo].[Objects_PotionObject]
ADD CONSTRAINT [PK_Objects_PotionObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_ScrollObject'
ALTER TABLE [dbo].[Objects_ScrollObject]
ADD CONSTRAINT [PK_Objects_ScrollObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_PillObject'
ALTER TABLE [dbo].[Objects_PillObject]
ADD CONSTRAINT [PK_Objects_PillObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_PortalObject'
ALTER TABLE [dbo].[Objects_PortalObject]
ADD CONSTRAINT [PK_Objects_PortalObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_StaffObject'
ALTER TABLE [dbo].[Objects_StaffObject]
ADD CONSTRAINT [PK_Objects_StaffObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_WandObject'
ALTER TABLE [dbo].[Objects_WandObject]
ADD CONSTRAINT [PK_Objects_WandObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Objects_TrashObject'
ALTER TABLE [dbo].[Objects_TrashObject]
ADD CONSTRAINT [PK_Objects_TrashObject]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [AreaId] in table 'Rooms'
ALTER TABLE [dbo].[Rooms]
ADD CONSTRAINT [FK_AreaRoom]
    FOREIGN KEY ([AreaId])
    REFERENCES [dbo].[Areas]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AreaRoom'
CREATE INDEX [IX_FK_AreaRoom]
ON [dbo].[Rooms]
    ([AreaId]);
GO

-- Creating foreign key on [RoomId] in table 'Exits'
ALTER TABLE [dbo].[Exits]
ADD CONSTRAINT [FK_RoomExit]
    FOREIGN KEY ([RoomId])
    REFERENCES [dbo].[Rooms]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RoomExit'
CREATE INDEX [IX_FK_RoomExit]
ON [dbo].[Exits]
    ([RoomId]);
GO

-- Creating foreign key on [ToRoom_Id] in table 'Exits'
ALTER TABLE [dbo].[Exits]
ADD CONSTRAINT [FK_ExitRoom]
    FOREIGN KEY ([ToRoom_Id])
    REFERENCES [dbo].[Rooms]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ExitRoom'
CREATE INDEX [IX_FK_ExitRoom]
ON [dbo].[Exits]
    ([ToRoom_Id]);
GO

-- Creating foreign key on [ExitKeyObject_KeyObject_Id] in table 'Objects_KeyObject'
ALTER TABLE [dbo].[Objects_KeyObject]
ADD CONSTRAINT [FK_ExitKeyObject]
    FOREIGN KEY ([ExitKeyObject_KeyObject_Id])
    REFERENCES [dbo].[Exits]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ExitKeyObject'
CREATE INDEX [IX_FK_ExitKeyObject]
ON [dbo].[Objects_KeyObject]
    ([ExitKeyObject_KeyObject_Id]);
GO

-- Creating foreign key on [Original_Id] in table 'Notes_ReplyNote'
ALTER TABLE [dbo].[Notes_ReplyNote]
ADD CONSTRAINT [FK_NoteReplyNote]
    FOREIGN KEY ([Original_Id])
    REFERENCES [dbo].[Notes]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_NoteReplyNote'
CREATE INDEX [IX_FK_NoteReplyNote]
ON [dbo].[Notes_ReplyNote]
    ([Original_Id]);
GO

-- Creating foreign key on [BoardId] in table 'Notes'
ALTER TABLE [dbo].[Notes]
ADD CONSTRAINT [FK_BoardNote]
    FOREIGN KEY ([BoardId])
    REFERENCES [dbo].[Boards]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_BoardNote'
CREATE INDEX [IX_FK_BoardNote]
ON [dbo].[Notes]
    ([BoardId]);
GO

-- Creating foreign key on [Account_Id] in table 'Characters_Player'
ALTER TABLE [dbo].[Characters_Player]
ADD CONSTRAINT [FK_AccountPlayer]
    FOREIGN KEY ([Account_Id])
    REFERENCES [dbo].[Accounts]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AccountPlayer'
CREATE INDEX [IX_FK_AccountPlayer]
ON [dbo].[Characters_Player]
    ([Account_Id]);
GO

-- Creating foreign key on [Board_Id] in table 'PlayerBoards'
ALTER TABLE [dbo].[PlayerBoards]
ADD CONSTRAINT [FK_BoardPlayerBoard]
    FOREIGN KEY ([Board_Id])
    REFERENCES [dbo].[Boards]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_BoardPlayerBoard'
CREATE INDEX [IX_FK_BoardPlayerBoard]
ON [dbo].[PlayerBoards]
    ([Board_Id]);
GO

-- Creating foreign key on [Player_Id] in table 'PlayerBoards'
ALTER TABLE [dbo].[PlayerBoards]
ADD CONSTRAINT [FK_PlayerPlayerBoard]
    FOREIGN KEY ([Player_Id])
    REFERENCES [dbo].[Characters_Player]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PlayerPlayerBoard'
CREATE INDEX [IX_FK_PlayerPlayerBoard]
ON [dbo].[PlayerBoards]
    ([Player_Id]);
GO

-- Creating foreign key on [AffectAbility_Ability_Id] in table 'Abilities'
ALTER TABLE [dbo].[Abilities]
ADD CONSTRAINT [FK_AffectAbility]
    FOREIGN KEY ([AffectAbility_Ability_Id])
    REFERENCES [dbo].[Affects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AffectAbility'
CREATE INDEX [IX_FK_AffectAbility]
ON [dbo].[Abilities]
    ([AffectAbility_Ability_Id]);
GO

-- Creating foreign key on [Character_Id] in table 'Affects_CharAffect'
ALTER TABLE [dbo].[Affects_CharAffect]
ADD CONSTRAINT [FK_CharacterCharAffect]
    FOREIGN KEY ([Character_Id])
    REFERENCES [dbo].[Characters]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CharacterCharAffect'
CREATE INDEX [IX_FK_CharacterCharAffect]
ON [dbo].[Affects_CharAffect]
    ([Character_Id]);
GO

-- Creating foreign key on [Object_Id] in table 'Affects_ObjectAffect'
ALTER TABLE [dbo].[Affects_ObjectAffect]
ADD CONSTRAINT [FK_ObjectObjectAffect]
    FOREIGN KEY ([Object_Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ObjectObjectAffect'
CREATE INDEX [IX_FK_ObjectObjectAffect]
ON [dbo].[Affects_ObjectAffect]
    ([Object_Id]);
GO

-- Creating foreign key on [Object_Id] in table 'CharObjs'
ALTER TABLE [dbo].[CharObjs]
ADD CONSTRAINT [FK_ObjectCharObj]
    FOREIGN KEY ([Object_Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ObjectCharObj'
CREATE INDEX [IX_FK_ObjectCharObj]
ON [dbo].[CharObjs]
    ([Object_Id]);
GO

-- Creating foreign key on [Character_Id] in table 'CharObjs'
ALTER TABLE [dbo].[CharObjs]
ADD CONSTRAINT [FK_CharacterCharObj]
    FOREIGN KEY ([Character_Id])
    REFERENCES [dbo].[Characters]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CharacterCharObj'
CREATE INDEX [IX_FK_CharacterCharObj]
ON [dbo].[CharObjs]
    ([Character_Id]);
GO

-- Creating foreign key on [Character_Id] in table 'Resets_CharReset'
ALTER TABLE [dbo].[Resets_CharReset]
ADD CONSTRAINT [FK_CharResetNonPlayer]
    FOREIGN KEY ([Character_Id])
    REFERENCES [dbo].[Characters_NonPlayer]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CharResetNonPlayer'
CREATE INDEX [IX_FK_CharResetNonPlayer]
ON [dbo].[Resets_CharReset]
    ([Character_Id]);
GO

-- Creating foreign key on [ContainerObjectKeyObject_KeyObject_Id] in table 'Objects_KeyObject'
ALTER TABLE [dbo].[Objects_KeyObject]
ADD CONSTRAINT [FK_ContainerObjectKeyObject]
    FOREIGN KEY ([ContainerObjectKeyObject_KeyObject_Id])
    REFERENCES [dbo].[Objects_ContainerObject]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ContainerObjectKeyObject'
CREATE INDEX [IX_FK_ContainerObjectKeyObject]
ON [dbo].[Objects_KeyObject]
    ([ContainerObjectKeyObject_KeyObject_Id]);
GO

-- Creating foreign key on [Object_Id] in table 'Resets_EquipReset'
ALTER TABLE [dbo].[Resets_EquipReset]
ADD CONSTRAINT [FK_EquipResetObject]
    FOREIGN KEY ([Object_Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_EquipResetObject'
CREATE INDEX [IX_FK_EquipResetObject]
ON [dbo].[Resets_EquipReset]
    ([Object_Id]);
GO

-- Creating foreign key on [NonPlayer_Id] in table 'Resets_GiveReset'
ALTER TABLE [dbo].[Resets_GiveReset]
ADD CONSTRAINT [FK_GiveResetNonPlayer]
    FOREIGN KEY ([NonPlayer_Id])
    REFERENCES [dbo].[Characters_NonPlayer]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GiveResetNonPlayer'
CREATE INDEX [IX_FK_GiveResetNonPlayer]
ON [dbo].[Resets_GiveReset]
    ([NonPlayer_Id]);
GO

-- Creating foreign key on [Object_Id] in table 'Resets_GiveReset'
ALTER TABLE [dbo].[Resets_GiveReset]
ADD CONSTRAINT [FK_GiveResetObject]
    FOREIGN KEY ([Object_Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GiveResetObject'
CREATE INDEX [IX_FK_GiveResetObject]
ON [dbo].[Resets_GiveReset]
    ([Object_Id]);
GO

-- Creating foreign key on [HelpHelp_Help1_Id] in table 'Helps'
ALTER TABLE [dbo].[Helps]
ADD CONSTRAINT [FK_HelpHelp]
    FOREIGN KEY ([HelpHelp_Help1_Id])
    REFERENCES [dbo].[Helps]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_HelpHelp'
CREATE INDEX [IX_FK_HelpHelp]
ON [dbo].[Helps]
    ([HelpHelp_Help1_Id]);
GO

-- Creating foreign key on [Help_Id] in table 'HelpTags'
ALTER TABLE [dbo].[HelpTags]
ADD CONSTRAINT [FK_HelpHelpTag]
    FOREIGN KEY ([Help_Id])
    REFERENCES [dbo].[Helps]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_HelpHelpTag'
CREATE INDEX [IX_FK_HelpHelpTag]
ON [dbo].[HelpTags]
    ([Help_Id]);
GO

-- Creating foreign key on [Area_Id] in table 'Characters_NonPlayer'
ALTER TABLE [dbo].[Characters_NonPlayer]
ADD CONSTRAINT [FK_NonPlayerArea]
    FOREIGN KEY ([Area_Id])
    REFERENCES [dbo].[Areas]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_NonPlayerArea'
CREATE INDEX [IX_FK_NonPlayerArea]
ON [dbo].[Characters_NonPlayer]
    ([Area_Id]);
GO

-- Creating foreign key on [Room_Id] in table 'Objects'
ALTER TABLE [dbo].[Objects]
ADD CONSTRAINT [FK_ObjectRoom]
    FOREIGN KEY ([Room_Id])
    REFERENCES [dbo].[Rooms]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ObjectRoom'
CREATE INDEX [IX_FK_ObjectRoom]
ON [dbo].[Objects]
    ([Room_Id]);
GO

-- Creating foreign key on [World_Id] in table 'Areas'
ALTER TABLE [dbo].[Areas]
ADD CONSTRAINT [FK_WorldArea1]
    FOREIGN KEY ([World_Id])
    REFERENCES [dbo].[Worlds]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_WorldArea1'
CREATE INDEX [IX_FK_WorldArea1]
ON [dbo].[Areas]
    ([World_Id]);
GO

-- Creating foreign key on [Area_Id] in table 'Objects'
ALTER TABLE [dbo].[Objects]
ADD CONSTRAINT [FK_AreaObject1]
    FOREIGN KEY ([Area_Id])
    REFERENCES [dbo].[Areas]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AreaObject1'
CREATE INDEX [IX_FK_AreaObject1]
ON [dbo].[Objects]
    ([Area_Id]);
GO

-- Creating foreign key on [CarriedBy_Id] in table 'Objects'
ALTER TABLE [dbo].[Objects]
ADD CONSTRAINT [FK_CharacterObject]
    FOREIGN KEY ([CarriedBy_Id])
    REFERENCES [dbo].[Characters]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CharacterObject'
CREATE INDEX [IX_FK_CharacterObject]
ON [dbo].[Objects]
    ([CarriedBy_Id]);
GO

-- Creating foreign key on [Object_Id] in table 'Resets_ObjReset'
ALTER TABLE [dbo].[Resets_ObjReset]
ADD CONSTRAINT [FK_ObjResetObject]
    FOREIGN KEY ([Object_Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ObjResetObject'
CREATE INDEX [IX_FK_ObjResetObject]
ON [dbo].[Resets_ObjReset]
    ([Object_Id]);
GO

-- Creating foreign key on [PotionScrollPillObjectSpell_Spell_Id] in table 'Abilities_Spell'
ALTER TABLE [dbo].[Abilities_Spell]
ADD CONSTRAINT [FK_PotionScrollPillObjectSpell]
    FOREIGN KEY ([PotionScrollPillObjectSpell_Spell_Id])
    REFERENCES [dbo].[Objects_PotionScrollPillObject]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PotionScrollPillObjectSpell'
CREATE INDEX [IX_FK_PotionScrollPillObjectSpell]
ON [dbo].[Abilities_Spell]
    ([PotionScrollPillObjectSpell_Spell_Id]);
GO

-- Creating foreign key on [Object_Id] in table 'Resets_PutReset'
ALTER TABLE [dbo].[Resets_PutReset]
ADD CONSTRAINT [FK_PutResetObject]
    FOREIGN KEY ([Object_Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PutResetObject'
CREATE INDEX [IX_FK_PutResetObject]
ON [dbo].[Resets_PutReset]
    ([Object_Id]);
GO

-- Creating foreign key on [Spell_Id] in table 'Objects_WandStaffObject'
ALTER TABLE [dbo].[Objects_WandStaffObject]
ADD CONSTRAINT [FK_WandStaffObjectSpell]
    FOREIGN KEY ([Spell_Id])
    REFERENCES [dbo].[Abilities_Spell]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_WandStaffObjectSpell'
CREATE INDEX [IX_FK_WandStaffObjectSpell]
ON [dbo].[Objects_WandStaffObject]
    ([Spell_Id]);
GO

-- Creating foreign key on [Room_Id] in table 'Characters'
ALTER TABLE [dbo].[Characters]
ADD CONSTRAINT [FK_RoomCharacter]
    FOREIGN KEY ([Room_Id])
    REFERENCES [dbo].[Rooms]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RoomCharacter'
CREATE INDEX [IX_FK_RoomCharacter]
ON [dbo].[Characters]
    ([Room_Id]);
GO

-- Creating foreign key on [Race_Id] in table 'Characters'
ALTER TABLE [dbo].[Characters]
ADD CONSTRAINT [FK_RaceCharacter]
    FOREIGN KEY ([Race_Id])
    REFERENCES [dbo].[Races]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RaceCharacter'
CREATE INDEX [IX_FK_RaceCharacter]
ON [dbo].[Characters]
    ([Race_Id]);
GO

-- Creating foreign key on [Class_Id] in table 'Characters_Player'
ALTER TABLE [dbo].[Characters_Player]
ADD CONSTRAINT [FK_ClassPlayer]
    FOREIGN KEY ([Class_Id])
    REFERENCES [dbo].[Classes]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ClassPlayer'
CREATE INDEX [IX_FK_ClassPlayer]
ON [dbo].[Characters_Player]
    ([Class_Id]);
GO

-- Creating foreign key on [SuperReset_Id] in table 'Resets_SubReset'
ALTER TABLE [dbo].[Resets_SubReset]
ADD CONSTRAINT [FK_SuperResetSubReset]
    FOREIGN KEY ([SuperReset_Id])
    REFERENCES [dbo].[Resets_SuperReset]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SuperResetSubReset'
CREATE INDEX [IX_FK_SuperResetSubReset]
ON [dbo].[Resets_SubReset]
    ([SuperReset_Id]);
GO

-- Creating foreign key on [Inside_Id] in table 'Objects'
ALTER TABLE [dbo].[Objects]
ADD CONSTRAINT [FK_ContainerObjectObject]
    FOREIGN KEY ([Inside_Id])
    REFERENCES [dbo].[Objects_ContainerObject]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ContainerObjectObject'
CREATE INDEX [IX_FK_ContainerObjectObject]
ON [dbo].[Objects]
    ([Inside_Id]);
GO

-- Creating foreign key on [Room_Id] in table 'Resets_SuperReset'
ALTER TABLE [dbo].[Resets_SuperReset]
ADD CONSTRAINT [FK_RoomSuperReset]
    FOREIGN KEY ([Room_Id])
    REFERENCES [dbo].[Rooms]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RoomSuperReset'
CREATE INDEX [IX_FK_RoomSuperReset]
ON [dbo].[Resets_SuperReset]
    ([Room_Id]);
GO

-- Creating foreign key on [Id] in table 'Objects_KeyObject'
ALTER TABLE [dbo].[Objects_KeyObject]
ADD CONSTRAINT [FK_KeyObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Notes_ReplyNote'
ALTER TABLE [dbo].[Notes_ReplyNote]
ADD CONSTRAINT [FK_ReplyNote_inherits_Note]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Notes]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Characters_Player'
ALTER TABLE [dbo].[Characters_Player]
ADD CONSTRAINT [FK_Player_inherits_Character]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Characters]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Affects_CharAffect'
ALTER TABLE [dbo].[Affects_CharAffect]
ADD CONSTRAINT [FK_CharAffect_inherits_Affect]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Affects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Affects_ObjectAffect'
ALTER TABLE [dbo].[Affects_ObjectAffect]
ADD CONSTRAINT [FK_ObjectAffect_inherits_Affect]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Affects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Resets_SuperReset'
ALTER TABLE [dbo].[Resets_SuperReset]
ADD CONSTRAINT [FK_SuperReset_inherits_Reset]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Resets]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Resets_CharReset'
ALTER TABLE [dbo].[Resets_CharReset]
ADD CONSTRAINT [FK_CharReset_inherits_SuperReset]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Resets_SuperReset]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Characters_NonPlayer'
ALTER TABLE [dbo].[Characters_NonPlayer]
ADD CONSTRAINT [FK_NonPlayer_inherits_Character]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Characters]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_ContainerObject'
ALTER TABLE [dbo].[Objects_ContainerObject]
ADD CONSTRAINT [FK_ContainerObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Resets_SubReset'
ALTER TABLE [dbo].[Resets_SubReset]
ADD CONSTRAINT [FK_SubReset_inherits_Reset]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Resets]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Resets_EquipReset'
ALTER TABLE [dbo].[Resets_EquipReset]
ADD CONSTRAINT [FK_EquipReset_inherits_SubReset]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Resets_SubReset]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Resets_GiveReset'
ALTER TABLE [dbo].[Resets_GiveReset]
ADD CONSTRAINT [FK_GiveReset_inherits_SubReset]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Resets_SubReset]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Resets_ObjReset'
ALTER TABLE [dbo].[Resets_ObjReset]
ADD CONSTRAINT [FK_ObjReset_inherits_SuperReset]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Resets_SuperReset]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_PotionScrollPillObject'
ALTER TABLE [dbo].[Objects_PotionScrollPillObject]
ADD CONSTRAINT [FK_PotionScrollPillObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Abilities_Spell'
ALTER TABLE [dbo].[Abilities_Spell]
ADD CONSTRAINT [FK_Spell_inherits_Ability]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Abilities]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Resets_PutReset'
ALTER TABLE [dbo].[Resets_PutReset]
ADD CONSTRAINT [FK_PutReset_inherits_SubReset]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Resets_SubReset]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_WandStaffObject'
ALTER TABLE [dbo].[Objects_WandStaffObject]
ADD CONSTRAINT [FK_WandStaffObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Classes_MageClass'
ALTER TABLE [dbo].[Classes_MageClass]
ADD CONSTRAINT [FK_MageClass_inherits_Class]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Classes]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Classes_WarriorClass'
ALTER TABLE [dbo].[Classes_WarriorClass]
ADD CONSTRAINT [FK_WarriorClass_inherits_Class]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Classes]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Races_PcRace'
ALTER TABLE [dbo].[Races_PcRace]
ADD CONSTRAINT [FK_PcRace_inherits_Race]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Races]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Races_HumanRace'
ALTER TABLE [dbo].[Races_HumanRace]
ADD CONSTRAINT [FK_HumanRace_inherits_PcRace]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Races_PcRace]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Races_DwarfRace'
ALTER TABLE [dbo].[Races_DwarfRace]
ADD CONSTRAINT [FK_DwarfRace_inherits_PcRace]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Races_PcRace]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_ArmorObject'
ALTER TABLE [dbo].[Objects_ArmorObject]
ADD CONSTRAINT [FK_ArmorObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_WeaponObject'
ALTER TABLE [dbo].[Objects_WeaponObject]
ADD CONSTRAINT [FK_WeaponObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Abilities_Skill'
ALTER TABLE [dbo].[Abilities_Skill]
ADD CONSTRAINT [FK_Skill_inherits_Ability]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Abilities]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Abilities_KickSkill'
ALTER TABLE [dbo].[Abilities_KickSkill]
ADD CONSTRAINT [FK_KickSkill_inherits_Skill]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Abilities_Skill]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Abilities_HealSpell'
ALTER TABLE [dbo].[Abilities_HealSpell]
ADD CONSTRAINT [FK_HealSpell_inherits_Spell]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Abilities_Spell]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Boards_AnnounceBoard'
ALTER TABLE [dbo].[Boards_AnnounceBoard]
ADD CONSTRAINT [FK_AnnounceBoard_inherits_Board]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Boards]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_DrinkContainerObject'
ALTER TABLE [dbo].[Objects_DrinkContainerObject]
ADD CONSTRAINT [FK_DrinkContainerObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_FoodObject'
ALTER TABLE [dbo].[Objects_FoodObject]
ADD CONSTRAINT [FK_FoodObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_FurnitureObject'
ALTER TABLE [dbo].[Objects_FurnitureObject]
ADD CONSTRAINT [FK_FurnitureObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_MoneyObject'
ALTER TABLE [dbo].[Objects_MoneyObject]
ADD CONSTRAINT [FK_MoneyObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_PotionObject'
ALTER TABLE [dbo].[Objects_PotionObject]
ADD CONSTRAINT [FK_PotionObject_inherits_PotionScrollPillObject]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects_PotionScrollPillObject]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_ScrollObject'
ALTER TABLE [dbo].[Objects_ScrollObject]
ADD CONSTRAINT [FK_ScrollObject_inherits_PotionScrollPillObject]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects_PotionScrollPillObject]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_PillObject'
ALTER TABLE [dbo].[Objects_PillObject]
ADD CONSTRAINT [FK_PillObject_inherits_PotionScrollPillObject]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects_PotionScrollPillObject]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_PortalObject'
ALTER TABLE [dbo].[Objects_PortalObject]
ADD CONSTRAINT [FK_PortalObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_StaffObject'
ALTER TABLE [dbo].[Objects_StaffObject]
ADD CONSTRAINT [FK_StaffObject_inherits_WandStaffObject]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects_WandStaffObject]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_WandObject'
ALTER TABLE [dbo].[Objects_WandObject]
ADD CONSTRAINT [FK_WandObject_inherits_WandStaffObject]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects_WandStaffObject]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'Objects_TrashObject'
ALTER TABLE [dbo].[Objects_TrashObject]
ADD CONSTRAINT [FK_TrashObject_inherits_Object]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[Objects]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------